import Vue from 'vue'
import Vuex from 'vuex'

import {
  getUserInfo
} from '../utils/wx'

Vue.use(Vuex)

export default new Vuex.Store({
  actions: {
    async getUserInfo ({
      commit
    }) {
      const {
        userInfo
      } = await getUserInfo()
      userInfo.avatar = userInfo.avatarUrl
      userInfo.name = userInfo.nickName
      userInfo.sex = userInfo.gender
    }
  }
})
